
package com.spring.demo;

import java.util.List;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class Application    {

	

	@Autowired
	private UserDao dao;

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	@GetMapping("/env")
	public String env(String name) {
		String val = System.getenv(name);
		String val2 = System.getProperty(name);
		String res = "val=" + val +";" + "val2=" + val2 ;
		return res;
	}



	@GetMapping("/save")
	public String save() {
		UserEntity user = new UserEntity();
		user.setId(new Random().nextLong());
		user.setName("用户" + new Random().nextInt(100));
		user.setPwd("123456");
		user.setAccount("test");
		dao.save(user);
		return "ok";
	}

	@GetMapping("/get")
	public List<UserEntity> get() {

		List<UserEntity> list = dao.findAll();
		return list;
	}

}

